﻿@model Cxuu.Models.EditArticleAndContent
@{
    ViewData["Title"] = await SystemConfig.GetByFieldNameAsync("SiteName");
    ViewData["UnitOfUse"] = await SystemConfig.GetByFieldNameAsync("UnitOfUse");
}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>@ViewData["Title"]</title>
    <link rel="stylesheet" href="~/lib/layui/css/layui.css">
    <link rel="stylesheet" href="~/admin/css/main.css">
    <style>
        html { zoom: 100%; width: 95%; margin: 5px auto; height: auto; }
        .cxuu-content-body { font-size: 16px; line-height: 30px; height: 30px; }
            .cxuu-content-body span { width: 80px; margin-left: 10px; }

        .cxuu-title { text-align:center;font-size: 26pt;height:50px;margin-top:20px; font-family:'黑体'; }
        .cxuu-table { border-collapse: collapse; width: 100%; height: 800px; border: 1px ridge rgb(0, 0, 0); margin-left: auto; margin-right: auto; }
        .cxuu-td { height: 80px; border-width: 1px; border-color: rgb(0, 0, 0); text-align: center; font-size: 12pt; }
        .cxuu-td-left { width: 120px; height: 100px; border-width: 1px; border-color: rgb(0, 0, 0); text-align: center; }
            .cxuu-td-left .pspan { font-size: 18pt; font-family: '黑体', sans-serif; }
        .cxuu-table-title { height: 100px; border-width: 1px; border-color: rgb(0, 0, 0); text-align: center; font-size: 22pt; padding: 20px; font-family: SimHei,'黑体'; }


        .cxuu-auther { font-size: 18px; width: 100%; height: 30px; line-height: 30px; font-family: '宋体'，'仿宋-GB2312','仿宋'; }
            .cxuu-auther li { text-align: left; float: left; width: 130px; }
    </style>
</head>
<body>
    <div class="layui-fluid">
       
        <fieldset class="layui-elem-field">
            <legend>文件内容</legend>
            <div class="layui-field-box">
                <!--startprintConttent-->
                <div style="width:87%;margin:auto;">
                    <div id="number" style="text-align:center;margin-top:320px; margin-bottom:5px; font-size:22px;"></div>
                    <div id="date" style="text-align:right;margin:10px 20px 20px 0; font-size:22px;"></div>
                    <div id="titleContent" style="text-align:center;margin:10px 0px 20px 0; font-size:24pt;font-family:SimHei;line-height:40px;padding:10px;"></div>
                    <div id="content">内容区域</div>

                    <div style="margin-top:30px;height:180px;">
                        <div style="font-size:18px; height:100px;line-height:30px;font-family:'宋体'，'仿宋-GB2312','仿宋';border-top-style:solid;border-top-width:1px;border-right-style:none;border-bottom-style:solid;border-bottom-width:1px;border-left-style:none;">
                            <div style="margin:5px 0 5px 0;">
                                <div id="leader" style="display:none;">
                                    <span>报：</span><span> </span>
                                </div>
                                <div id="department" style="display:none;">
                                    <span>送：</span><span> </span>
                                </div>
                            </div>
                            <div style="text-align:right;margin-right:18px;">
                                [ 存档1份  共印4份 ]
                            </div>
                        </div>
                        <div class="cxuu-auther">
                            <ul>
                                <li>编辑：<span id="autherContent"></span></li>
                                <li>校对：<span id="proofread"></span></li>
                                <li>初审：<span id="earlierExa"> </span></li>
                                <li style="float:right;text-align:right;">审签：<span id="examine"> </span></li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!--endprintConttent-->
            </div>
        </fieldset>

        <br />
        <div style="text-align:center;">
            <input type="button" class="layui-btn" onclick="previewConttent()" value="打印内容">
        </div>
        <br />


        <fieldset class="layui-elem-field">
            <legend>附件 <span style="font-size:14px;">点击文件名下载</span></legend>
            <div class="layui-field-box">
                <script id="attments" type="text/html">
                    <h3>{{ d.title }}</h3>
                    <ul>
                    {{#  layui.each(d.list, function(index, item){ }}
                      <li>
                         <span><a href="{{ item.url }}" style="color:forestgreen; font-size:16px;" download="{{ item.filename }}">{{ item.filename }} </a></span>
                        <span style="margin-right:0px;">{{ item.time }}</span>
                      </li>
                    {{#  }); }}
                    {{#  if(d.list.length === 0){ }}
                      无附件
                    {{#  } }}
                    </ul>
                </script>
                <div id="attmentsView"></div>
            </div>
        </fieldset>



    </div>
    <script src="~/lib/layui/layui.js"></script>
    <script>
        layui.define(function () {
            var form = layui.form, layer = layui.layer, $ = layui.jquery, element = layui.element, laytpl = layui.laytpl;
            var laydate = layui.laydate;

            $.getJSON("/Admin/Article/AddOrEdit?id=@ViewBag.id&edit=1", function (res) {
                if (res.status == 1) {
                    var data = res.data;
                    var miji;

                    switch (data.miji) {
                        case 1:
                            miji = "秘密";
                            break;
                        case 2:
                            miji = "机密";
                            break;
                        case 3:
                            miji = "绝密";
                            break;
                        default:
                            miji = "无";
                    }
                    var objectDate = new Date();
                    var day = objectDate.getDate();
                    var month = objectDate.getMonth() + 1;
                    var year = objectDate.getFullYear();

                    $("#date").html(year + "&nbsp;&nbsp;&nbsp;  " + month + "&nbsp;&nbsp;&nbsp;  " + day);
                    $("#title").html(data.title);
                    $("#titleContent").html(data.title);
                    $("#docNumber").html(data.docNumber);
                    $("#number").html(data.docNumber);

                    var greatTime = data.greatTime;
                    var arr = greatTime.split(' ');
                    $("#greattime").html(arr[0]);


                    $("#auther").html(data.auther);
                    $("#autherContent").html(data.auther);
                    $("#miji").html(miji);
                    $("#cateName").html(data.cateName);
                    $("#deptName").html(data.deptName);
                    $("#remarks").html(data.remarks);
                    $("#content").html(data.content);
                    if (data.leader != null) {
                        $("#leader").show();
                        $("#leader").html(" <span>报：</span><span > " + data.leader + "</span>");
                    }
                    if (data.department != null) {
                        $("#department").show();
                        $("#department").html(" <span>送：</span><span > " + data.department + "</span>");
                    }
                    $("#proofread").html(data.proofread);
                    $("#earlierExa").html(data.earlierExa);
                    $("#examine").html(data.examine);

                    var att = res.attments;
                    // 附件列表模板渲染
                    if (att !== null) {
                        var data = {
                            // "title": "附件列表:"
                            "list": att
                        }
                        var getTpl = attments.innerHTML
                            , view = document.getElementById('attmentsView');
                        laytpl(getTpl).render(data, function (html) {
                            view.innerHTML = html;
                        });
                    }
                } else {

                }
            });

        });

        function previewConttent() {
            bdhtml = window.document.body.innerHTML;
            // 打印开始的标志
            sprnstr = "<!--startprintConttent-->";
            // 打印结束的标志
            eprnstr = "<!--endprintConttent-->";
            // 从打印开始的位置截取到末尾
            prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 25);
            // 从开始截取到打印结束的位置
            prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
            // 替换html
            window.document.body.innerHTML = prnhtml;
            // 打印
            window.print();
            window.document.body.innerHTML = bdhtml;
        }


    </script>

</body>
</html>